package mudclient;

import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;

public class MudClientConnectDialog extends JDialog {
	public MudClientConnectDialog(JFrame frame) {
		super(frame, true);
		initComponents();
	}
	
	private void initComponents() {
		hnl = new JLabel();
		pl = new JLabel();
		hnf = new JTextField();
		pf = new JTextField();
		ok = new JButton();
		
		hnl.setText("Hostname:");
		pl.setText("Port:");
		ok.setText("OK");
		
		GroupLayout gp = new GroupLayout(getContentPane());
		getContentPane().setLayout(gp);
		gp.setHorizontalGroup(
			gp.createParallelGroup(GroupLayout.Alignment.CENTER).
				addGroup(gp.createSequentialGroup().
					addContainerGap().
					addGroup(gp.createParallelGroup().
						addComponent(hnl).
						addComponent(pl)
					).
					addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).
					addGroup(gp.createParallelGroup().
						addComponent(hnf, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE).
						addComponent(pf, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
					).
					addContainerGap()
				).
			addComponent(ok)
		);
		gp.setVerticalGroup(
			gp.createSequentialGroup().
				addContainerGap().
				addGroup(gp.createParallelGroup().
					addComponent(hnl).
					addComponent(hnf)
				).
				addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).
				addGroup(gp.createParallelGroup().
					addComponent(pl).
					addComponent(pf)
				).
				addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).
				addComponent(ok).
				addContainerGap()
		);
		
		this.pack();
	}
	
	public void addOKActionListener(ActionListener al) {
		ok.addActionListener(al);
	}
	
	public String getHostName() { 
		return hnf.getText();
	}
	
	public String getPort() { 
		return pf.getText();
	}
	
	private JLabel hnl;
	private JLabel pl;
	private JTextField hnf;
	private JTextField pf;
	private JButton ok;
}
